<template>

    <div class="shopcar-container">

        <div class="goods-list">

            <!-- 商品列表项区域 -->
            <div class="mui-card">
                <div class="mui-card-content">
                    <div class="mui-card-content-inner">
                       <mt-switch></mt-switch>
                       <img src="../../images/01-xiaomi.jpg" >

                       <div class="info">
                        <h1>小米(MI)小米Note 16G双网通版</h1>
                            <p>
                               <span class="price">￥1299</span>
                                <!-- <numbox></numbox> -->
                               <a href="#">删除</a>
                            </p>
                       </div>
                    </div>
                    <div class="mui-card-content-inner">
                       <mt-switch></mt-switch>
                       <img src="../../images/01-xiaomi.jpg" >

                       <div class="info">
                        <h1>小米(MI)小米Note 16G双网通版</h1>
                            <p>
                               <span class="price">￥1299</span>
                                <!-- <numbox></numbox> -->
                               <a href="#">删除</a>
                            </p>
                       </div>
                    </div>
                    <div class="mui-card-content-inner">
                       <mt-switch></mt-switch>
                       <img src="../../images/01-xiaomi.jpg">

                       <div class="info">
                        <h1>小米(MI)小米Note 16G双网通版</h1>
                            <p>
                               <span class="price">￥1299</span>
                                <!-- <numbox></numbox> -->
                               <a href="#">删除</a>
                            </p>
                       </div>
                    </div>
                </div>
            </div>

            <!-- 结算区域 -->
            <div class="mui-card">
                <div class="mui-card-content">
                    <div class="mui-card-content-inner jiesuan">
                      <div class="left">
                          <p>总计(不含运费)</p>
                          <p>已勾选商品<span class="red">0</span>件，总价<span  class="red">￥0</span></p>
                      </div>
                      <mt-button type="danger">结算</mt-button>
                    </div>

                </div>
            </div>

        </div>
    </div>
</template>


<script>
    import Vue from 'vue'
   // import numbox from '../subcomponents/shopcar_numbox.vue';

    export default {
        data(){
            return {

            }
        },
        created(){
            this.getGoodsList()
        },
        methods:{
            //获取到store中所有的商品ID ，然后拼接出一个 用逗号分隔的字符串
            getGoodsList(){
                var idArr = [];
                this.$store.state.car.forEach(item => idArr.push(item.id));
            //如果购物车中没有商品，则直接返回，不需要请求数据接口，否则会报错
                if(idArr.length <= 0){
                    return;
                }
                //获取购物车商品列表
                this.$http
                .get("app/goods/getshopcarlist/" +idArr.join(","))
                .then(result => {
                    if(result.body.status === 0){
                        this.goodslist = result.body.message;
                    }
                })
            }
        },
        components:{
            // numbox
        }
    }

</script>



<style lang="scss" scoped>
.shopcar-container{
    background-color:#eee;
    overflow:hidden;
    .goods-list{
        .mui-card-content-inner{
            display:flex;
            align-items:center;

        }
        img{
            width:60px;
            height:60px;
        }
        h1{
            font-size:13px;
        }
        .info{
            .price{
                color:red;
                font-weight:bold;
            }
        }
    }
    .jiesuan{
        display:flex;
        justify-content: space-between;
        align-item:center;
        .red{
            color:red;
            font-weight:bold;
            font-size:16px;
        }
    }
}

</style>
